home *** CD-ROM | disk | FTP | other *** search
- /* Packet Maximiser 2.5 (MaxPKT) by Mat Bettinson of UK Xenolink alliance
-
- Xenolink (and some other tossers) has a VERY annoying habit of creating a
- great deal of poxy small mail archives. This is totally unecessary and can
- annoy due to the extra files, blocks required for them. Size of the outbound
- file listing and the turn around time of Transfer protocols for each file.
-
- MaxPKT basically shoves all the waiting packets for all nodes in a single
- archive for each of your systems in the outbound.
-
- MaxPKT should be fairly quick and once run again will quickly decide if
- there's no work to do, so is ideal for Croning and/or scripting.
-
- LHA and Copy and Delete should be in your path. If they AINT you have a
- real weird system. :-)
-
- No problems have been faced with packets deleted and not appended... Yet.
- I take no responsibility for this program eating all your mail because
- you have the Zimbawean version of LHA where 'c' means DELETE HD. :-)
-
- Just modify the Outbound line below and you're away. (Must have / or : at
- the end as shown)
-
- NEW to 2.1: You can over-ride the default with an arg on the command line.
- IE rx MaxPKT XOUT: will treat XOUT: as your outbound.
-
- NEW to 2.2: All files now renamed to the current date extention IE TU0.
-
- NEW to 2.5: Checks that files are LHA archives. Oops! Should have thought
- of that! Bloody PC users! :-)
-
- NB: This script will ONLY work on packets named *.*.*.*.TH1 etc...
- */
-
- Outbound = 'BBS:temp/'
-
- /**** Program begins. Leave alone unless feeling lucky! :-) ****/
-
- ARG outarg
-
- SAY ''
- SAY "*** MaxPKT 2.5 by Mat Bettinson of UK Xenolink Alliance, Dec '94. ***"
- SAY ''
-
- If outarg = '' & Outbound = '' then DO
- SAY 'Usage: [rx] MaxPKT <outbound dir>'
- SAY ' or edit script header to change default.'
- SAY ''
- EXIT
- END
- If outarg = '' then DO
- SAY 'Using default outbound: 'Outbound
- SAY ''
- END
- ELSE DO
- If Right(outarg,1) ~= ':' & Right(outarg,1) ~= '/' then outarg = outarg'/'
- Outbound = outarg
- END
- SAY 'Listing...'
- Address COMMAND 'LIST 'Outbound' LFORMAT "%m.%e %l" >t:Max.tmp'
- Numsys = 0
- Nothing = 1
- DelF = 0
- CALL Open(list,'t:Max.tmp','R')
- /* Open list of Outbound and scan for mail related files. */
- SAY 'Analysing...'
- DO forever
- Line = readLN(list)
- IF EOF(list) THEN break
- Lsize = strip(word(line,2))
- Lfile = word(line,1)
- IF (Lsize ~= 'Dir') & right(Lfile,2) ~= 'UT' & (Datatype(right(Lfile,1)) = 'NUM' | right(Lfile,2) = 'LO') then DO
- CALL CallCheck
- END
- END
- /* Finds the biggest packet. (No point adding a LARGE packet to a tiny one! */
- SAY 'Sorting...'
- DO i = 1 TO Numsys
- NumPKT = Words(Hexname.i) - 1
- last = 0
- DO l = 1 TO NumPKT
- TmpSize=word(Filesiz.i,l)
- IF TmpSize>last THEN Biggest = l
- last = TmpSize
- END
- IF NumPKT > 1 THEN DO
- BigFile.i = word(Hexname.i,Biggest+1)
- END
- ELSE Bigfile.i = ''
- END
- DO move = 1 TO NumSYS
- NumPKT = words(Hexname.move) - 1
- nope = 0
- IF NumPKT < 2 THEN nope = 1
- Del.move = ''
- IF nope = 0 THEN CALL Movem
- END
- /* After moving we better remove the Flo-file entries for the deleted packets! */
- IF nothing = 0 then SAY 'Fixing Flo-files...'
- DO move = 1 TO NumSYS
- IF Del.Move ~= '' & left(Flofile.move,3) ~= 'FLO' THEN DO
- CALL Open(flo,Outbound||Flofile.move,'R')
- CALL Open(out,'t:Max.tmp2','W')
- TodayExt = Word(Hexname.move,1)'.'UPPER(left(date('W'),2))'0'
- Address COMMAND 'Rename 'Outbound||Bigfile.move' TO 'Outbound||TodayExt
- Del.move = Del.move' 'Bigfile.move
- Nothing = 0
- DO forever
- fm = READLN(flo)
- IF EOF(flo) THEN break
- chk = Translate(fm,' ',':/')
- floname = strip(word(chk,words(chk)))
- IF INDEX(Del.move,floname) = 0 THEN CALL WriteLN(out,fm)
- END
- Call WriteLN(out,'^'Outbound||TodayExt)
- CALL Close(flo)
- CALL Close(out)
- Address COMMAND 'Copy >NIL: t:Max.tmp2 'Outbound||Flofile.move
- END
- END
- IF nothing = 1 THEN DO
- SAY
- SAY 'No Packets to Maximize!'
- END
- Call Close(list)
- Address COMMAND 'Delete >NIL: t:Max.t#?'
- SAY ''
- SAY 'MaxPKT finished. 'DelF' files deleted.'
- SAY ''
- EXIT
- /* The move routing... Appends the Archives to the largest */
- Movem:
- SAY 'Maxing node: 'Word(Hexname.move,1)'...'
- DO pkt = 1 TO NumPKT
- Name = strip(word(Hexname.move,pkt+1))
- IF Name ~= Bigfile.move & Datatype(right(name,1)) = 'NUM' THEN DO
- Call CheckLha
- IF LHA then DO
- Address COMMAND 'LHA -q c 'Outbound||Bigfile.move' 'Outbound||name
- Address COMMAND 'Delete >NIL: 'Outbound||name
- Del.move = Del.move' 'Name
- Delf = Delf + 1
- END
- END
- END
- RETURN
- /* This validates the filenames. If a system the call Findsys */
- CallCheck:
- Parse VAR Line name size
- system = left(name,length(name)-4)
- CALL Findsys
- IF right(name,2) = 'LO' THEN DO
- flofile.res = name
- RETURN
- END
- Hexname.res = Hexname.res' 'name
- Filesiz.res = Filesiz.res' 'strip(size)
- RETURN
- /* This installs new systems as they are discovered... */
- Findsys:
- DO res = 1 TO Numsys
- IF word(Hexname.res,1) = system THEN RETURN
- END
- Numsys = Numsys + 1
- res = Numsys
- Hexname.res = system
- Filesiz.res = ''
- RETURN
-
- Call CheckLHA:
- archive = Outbound||name
- Call Open('TLHA',archive,'R')
- Arctest = READCH('TLHA',7)
- Call Close('TLHA')
- Arctest = Right(arctest,5)
- Arctest = Overlay('x',Arctest,4)
- If Arctest = '-lhx-' then LHA = 1
- ELSE DO
- SAY 'WARNING: System 'Word(Hexname.move,1)' is not using LHA! Skipping...'
- LHA = 0
- END
- RETURN
-